import {getCategory,getCategoryTab,getCategoryDetail,getCategoryDetailList} from '../../api';

export function categoryAction(){
    return async(dispatch:Function)=>{
        const result = await getCategory();
        dispatch({
            type:'INIT_CATEGORY',
            payload:result.data
        })
    }
}

export function categoryTab(id:number){
    return async(dispatch:Function)=>{
        const result = await getCategoryTab(id);
        dispatch({
            type:"SET_TAB",
            payload:result.data
        })
    }
}
export function categoryDetail(id:string){
    return async(dispatch:Function)=>{
        const result = await getCategoryDetail(id);
        dispatch({
            type:"SET_DETAIL",
            payload:result.data
        })
    }
}
export function categoryDetailList(page?:string,size?:string,categoryId?:string){
    return async(dispatch:Function)=>{
        const result = await getCategoryDetailList(page,size,categoryId);
        dispatch({
            type:"SET_DETAILLIST",
            payload:result.data
        })
    }
}
